import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kxy_flutter_app/view/examination/view_model/exam_model.dart';
import 'package:kxy_flutter_app/view/examination/view_model/test_model.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:kxy_flutter_app/view/my/integral/integral_rank_model.dart';
import 'package:kxy_flutter_app/view/my/rank/view_model/exam_rank_model.dart';
import 'package:kxy_flutter_app/view/root/view_model/app_info_model.dart';
import 'package:kxy_flutter_app/view/root_view.dart';
import 'package:provider/provider.dart';
import 'components/chinese_cupertino_localizations.dart';
import 'view/my/basic_info/view_model/user_info_editor_model.dart';
import 'view/my/view_model/my_view_model.dart';
import 'view/root/login_view.dart';
import 'view/root/tab_view.dart';
import 'view/root/view_model/auth_model.dart';
import 'view/root/view_model/login_model.dart';
import 'view/root/view_model/navigation_model.dart';

void main() {
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => new AuthModel()),
        ChangeNotifierProvider(create: (_) => new UserInfoEditorModel()),
        ChangeNotifierProvider(create: (_) => new MyViewModel()),
        ChangeNotifierProvider(create: (_) => new LoginModel()),
        ChangeNotifierProvider(create: (_) => new NavigationModel()),
        ChangeNotifierProvider(create: (_) => new ExamModel()),
        ChangeNotifierProvider(create: (_) => new TestModel()),
        ChangeNotifierProvider(create: (_) => new ExamRankModel()),
        ChangeNotifierProvider(create: (_) => new IntegralRankModel()),
        ChangeNotifierProvider(create: (_) => new AppInfoModel()),
      ],
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      localizationsDelegates: [
        ChineseCupertinoLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: [
        Locale('zh', 'CH'),
        Locale('en', 'US'),
      ],
      locale: Locale('zh'),
      theme: ThemeData(
        primaryColor: Color.fromRGBO(40, 126, 237, 1),
        backgroundColor: Color.fromRGBO(245, 245, 245, 1),
        canvasColor: Color.fromRGBO(245, 245, 245, 1),
        textTheme: TextTheme(
          headline6: TextStyle(
            color: Colors.black,
            fontSize: 16,
            fontWeight: FontWeight.bold,
          ),
          subtitle1: TextStyle(
            color: Colors.black,
            fontSize: 14,
          ),
          subtitle2: TextStyle(
            color: Colors.black,
            fontSize: 14,
          ),
          bodyText2: TextStyle(
            color: Colors.black87,
            fontSize: 14,
          ),
          bodyText1: TextStyle(
            color: Colors.black54,
            fontSize: 12,
          ),
        ),
        appBarTheme: AppBarTheme(
          color: Colors.white,
          brightness: Brightness.light,
          elevation: 1,
          iconTheme: IconThemeData(color: Colors.black),
          textTheme: TextTheme(
            headline6: TextStyle(
              color: Colors.black,
              fontSize: 18,
              // fontWeight: FontWeight.bold,
            ),
          ),
        ),
        buttonTheme: ButtonThemeData(
          height: 32,
          minWidth: 64,
        ),
      ),
      home: RootView(),
      routes: {
        '/home': (cxt) => TabView(),
        '/login': (cxt) => LoginView(),
      },
    );
  }
}
